package com.skt.common_hr.common.puremvc
{
	import mx.managers.CursorManager;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;

	public class DataReceiver
	{
		public var retCode:int;
		public var retText:String;
		public var faultDetail:String;
		public var result:Object;
		public var type:String;
		private var _owner:CommonProxy;
		private var resultCallback:Function = null;

		public function DataReceiver(owner:CommonProxy, result:Function, type:String=null)
		{
			resultCallback = result;
			_owner = owner;
			this.type = type;
		}

		public function resultHandler(event:ResultEvent):void
		{
			result = event.result;
			_owner.retCode = retCode = event.result["RETCODE"];
			_owner.retText = retText = event.result["RETTEXT"];
			resultCallback(this);
			CursorManager.removeBusyCursor();
		}
		
		public function faultHandler(event:FaultEvent):void
		{
			_owner.retCode = retCode = -1;
			_owner.retText = retText = "["+event.fault.faultCode+"]"+event.fault.faultString;
			_owner.faultDetail = faultDetail = event.fault.faultDetail;
			result = null;
			resultCallback(this);	
			CursorManager.removeBusyCursor();
		}
	}
}